<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * 礼品订单管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return['params']=array();
	exi($return);
}
if($_RQ['op']=='flog'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	$params['mid']=$_SESSION['uid'];
	if(!empty($_RQ['ordersn'])){
		$params['ordersn']=$_RQ['ordersn'];
		$return['params']['ordersn']=$_RQ['ordersn'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_vote_sendlplog',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['createtime']=date('Y-m-d',$item['createtime']);
			$item['title']=pdo_getcolumn('jy_vote_opus',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['oid']),'title');
			$mid=pdo_getcolumn('jy_vote_opus',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['oid']),'mid');
			$user=pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'id'=>$mid),array('nickname','avatar','sex'));		
			$item['nickname2']=$user['nickname'];
			$item['avatar2']=$user['avatar'];
			$item['sex2']=$user['sex'];
		}
	}
	$return['list']=$list;
	$return['params']['page'] =$pindex;
	exi($return);
}
if($_RQ['op']=='slog'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	$oids=pdo_getall('jy_vote_opus',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'mid','mid');
	if($oids){
		$oids=array_keys($oids);
		$params['oid']=$oids;
	}else{
		$params['oid']=-1;
	}
	if(!empty($_RQ['ordersn'])){
		$params['ordersn']=$_RQ['ordersn'];
		$return['params']['ordersn']=$_RQ['ordersn'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_vote_sendlplog',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['createtime']=date('Y-m-d',$item['createtime']);
			$item['title']=pdo_getcolumn('jy_vote_opus',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['oid']),'title');
			$mid=pdo_getcolumn('jy_vote_opus',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['oid']),'mid');
			$user=pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['mid']),array('nickname','avatar','sex'));		
			$item['nickname']=$user['nickname'];
			$item['avatar']=$user['avatar'];
			$item['sex']=$user['sex'];
		}
	}
	$return['list']=$list;
	$return['params']['page'] =$pindex;
	exi($return);
}